<template>
	<div>
		<el-dialog title="审查自定义-肾损害剂量" :visible.sync="dialogVisibleJiLiang" width="1025px">
			<el-card class="box-card" style="margin-top:15px">
				<el-row :gutter="15">
					<el-form label-width="120px">
						<el-col :span="12">
							<el-form-item label="给药途径">
								<el-input v-model="dosingUnit_name"  :readonly="true"  size="mini" style="width:150px;"></el-input>
								<el-button type="primary" size="mini" @click="openSelect(1)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun(1)">清除</el-button>
							</el-form-item>
						</el-col>	
						<el-col :span="12">
							<el-form-item label="选择肾损害程度">
								<el-select v-model="submit.degree" size="small" placeholder="请选择" >
									<el-option  label="无肾损害" value="0"></el-option>
									<el-option  label="肾功能不全" value="1"></el-option>
									<el-option  label="轻度肾损害" value="2"></el-option>
									<el-option  label="中度肾损害" value="3"></el-option>
									<el-option  label="重度肾损害" value="4"></el-option>
								</el-select>
							</el-form-item>
						</el-col>	
						<el-col :span="12">
							<el-form-item label="选择肝损害程度">
								<el-select v-model="submit.liver" size="small" placeholder="请选择" >
									<el-option  label="无肝损害" value="0"></el-option>
									<el-option  label="肝功能不全" value="1"></el-option>
									<el-option  label="轻度肝损害" value="2"></el-option>
									<el-option  label="中度肝损害" value="3"></el-option>
									<el-option  label="重度肝损害" value="4"></el-option>
								</el-select>
							</el-form-item>
						</el-col>	
						<el-col :span="12">
							<el-form-item label="选择检验值指标">
								<el-input v-model="renalDescription_name"  :readonly="true"  size="mini" style="width:150px;"></el-input>
								<el-button type="primary" size="mini" @click="openSelect(3)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun(3)">清除</el-button>
							</el-form-item>
						</el-col>
					</el-form>
					<el-form label-width="80px">
						<el-col :span="24" style="border-bottom:1px dashed #afafaf;margin-bottom:16px;"></el-col>
						<el-col :span="12">
							<el-form-item label="给药单位">
								<el-select v-model="submit.dosingUnit" size="small" placeholder="请选择">
									<el-option  label="ml" value="ml">
									</el-option>
								  </el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="计算方式">
								<el-select v-model="submit.calculation" size="small" placeholder="请选择">
									<el-option  label="常规" value="1"></el-option>
									<el-option  label="体重" value="2"></el-option>
									<el-option  label="体表" value="3"></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="年龄低值">
								<div class="dialogFirstRow">
									<el-select v-model="submit.age_low" size="mini">
										<el-option label=">=" value="0"></el-option>
										<el-option label=">" value="1"></el-option>
									</el-select>
									<el-input v-model="submit.ageLow" v-only-number="{max:10000000000,min:0,precision:0}" size="mini" ></el-input>
									<el-select v-model="submit.age_low_unit" size="mini">
										<el-option v-for="item in ageOptions" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="年龄高值">
								<div class="dialogFirstRow">
									<el-select v-model="submit.age_high" size="mini">
										<el-option label="<=" value="0"></el-option>
										<el-option label="<" value="1"></el-option>
									</el-select>
									<el-input v-model="submit.ageH" v-only-number="{max:10000000000,min:0,precision:0}" size="mini"></el-input>
									<el-select v-model="submit.age_high_unit" size="mini">
										<el-option v-for="item in ageOptions" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="疾病状态">
								<el-input v-model="diseaseName"  :readonly="true"  size="mini" style="width:150px;"></el-input>
								<el-button type="primary" size="mini" @click="openSelect(2)">选择</el-button>
								<el-button type="primary" size="mini" @click="clearFun(2)">清除</el-button>
							</el-form-item>
						</el-col>
						<el-col :span="24" style="border-bottom:1px dashed #afafaf;margin-bottom:16px;"></el-col>
						<el-col :span="12">
							<el-form-item label="每次剂量">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.doseRangeL" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/ml</div>
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.doseRangeH" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日/ml</div>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="每日剂量">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.dailyDoseL" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/ml</div>
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.dailyDoseH" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日/ml</div>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="给药频次">
								<div style="display:inline-block;">低值/</div>
								<el-input v-model="submit.dosingFrequencyLow" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/</div>
								<el-input v-model="submit.dosingFrequencyLowDay" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日</div>
								
								<div style="display:inline-block;">高值/</div>
								<el-input v-model="submit.dosingFrequencyHight" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">次/</div>
								<el-input v-model="submit.dosingFrequencyHightDay" size="small" style="width:60px;"></el-input>
								<div style="display:inline-block;">日</div>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="频次描述">
								<el-input v-model="submit.dosingFrequency" size="big"></el-input>
							</el-form-item>
						</el-col>
					</el-form>
				</el-row>
			</el-card>
			<span slot="footer" class="dialog-footer">
			    <el-button type="primary" @click="save">保 存</el-button>
			  </span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		name:"sshSetCard",
		data () {
			return {
				sshcdVal:"",
				gshcdVal:"",
				ageOptions:[
					{
					  value: '岁',
					  label: '岁'
					},
					{
					  value: '月',
					  label: '月'
					},
					{
					  value: '天',
					  label: '天'
					},
				],
				dosingUnit_name:"",
				diseaseName:"",
				renalDescription_name:"",
				submit:{
					drug_route:"",
					dosingUnit:"ml",
					calculation:"1",
					degree:"0",
					liver:"0",
					renalDescription:"",
					age_low:"0",
					ageLow:"",
					age_low_unit:"岁",
					age_high:"0",
					ageH:"",
					age_high_unit:"岁",
					diseaseStates:"",
					doseRangeL:"",
					doseRangeH: "",
					dailyDoseL:"",
					dailyDoseH:"",
					dosingFrequencyLow: "",
					dosingFrequencyLowDay:"",
					dosingFrequencyHight:"",
					dosingFrequencyHightDay:"",
					dosingFrequency:""
				},
				dialogVisibleJiLiang:false,
			}
		},
		props:{
			nowData:{
				type:Object
			},
			gyData:{
				type:Object
			},
			jbData:{
				type:Object
			},
			sgnjyData:{
				type:Object
			}
		},
		watch:{
			gyData(val){
				this.dosingUnit_name=val.name;
				this.submit.drug_route=val.id
			},
			jbData(val){
				this.diseaseName=val.name;
				this.submit.diseaseStates=val.id;
			},
			sgnjyData(val){
				this.renalDescription_name=val.name;
				this.submit.renalDescription=val.id;
			}
		},
		methods:{
			async save(){
				console.log(this.nowData)
				if(!this.submit.drug_route){
					this.$message({
					  message: "请输入择要设置的给药途径",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.renalDescription){
					this.$message({
					  message: "请输入择要设置的肾功能检验指标",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.ageLow){
					this.$message({
					  message: "请输入择要设置的年龄低值",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.ageH){
					this.$message({
					  message: "请输入择要设置的年龄高值",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				if(!this.submit.diseaseStates){
					this.$message({
					  message: "请输入择要设置的疾病状态",
					  type:'error',
					  duration:1500
					});
					return false;
				}
				let newObj = {drugUniqueCode:this.nowData.drugUniqueCode};
				console.log(this.nowData)
				Object.assign(newObj,this.submit);
				let res=await this.$custom.listrenalDamageSave(newObj)
				if(res){
					this.$message({
					  message: res.msg,
					  type: res.code == 1?'success':'error',
					  duration:1500
					});
					if(res.code == 1){
						this.resetFun();
					}
					this.$emit("changeFun")
				}
			},
			show () {
				this.dialogVisibleJiLiang = true;
			},
			clearFun(type){
				if(type == 1){
					this.dosingUnit_name="";
					this.submit.drug_route="";
				}else if(type == 2){
					this.diseaseName="";
					this.submit.diseaseStates="";
				}else if(type == 3){
					this.renalDescription_name="";
					this.submit.renalDescription="";
				}
			},
			openSelect (type) {
				if(type == 1){
					this.$emit("selectPop","给药",this.submit.drug_route);
				}else if(type ==2){
					this.$emit("selectPop","疾病",this.submit.diseaseStates);
				}else if(type ==3){
					if(this.submit.renalRadio = 2){
						this.$emit("selectPop","肾功能检验",this.submit.renalDescription);
					}
				}
			},
			resetFun(){
				this.dosingUnit_name="";
				this.diseaseName="";
				this.renalDescription_name="";
				this.submit={
					drug_route:"",
					dosingUnit:"ml",
					calculation:"1",
					degree:"0",
					liver:"0",
					renalDescription:"",
					age_low:"0",
					ageLow:"",
					age_low_unit:"岁",
					age_high:"0",
					ageH:"",
					age_high_unit:"岁",
					diseaseStates:"",
					doseRangeL:"",
					doseRangeH: "",
					dailyDoseL:"",
					dailyDoseH:"",
					dosingFrequencyLow: "",
					dosingFrequencyLowDay:"",
					dosingFrequencyHight:"",
					dosingFrequencyHightDay:"",
					dosingFrequency:""
				};
			}
		}
	}
</script>

<style lang="scss" scoped>
	.el-card {
		margin-left: 3px;
	}
	.dialogFirstRow>>>.el-input {
		width: 70px;
		margin-right: 10px;
	}
	
	.el-form-item.s_selectbox>>>.el-form-item__content {
		width: 80%;
	}
	
	
	.demo-form-inline>>>.el-form-item {
		margin-bottom: 0px;
	}
	
	.dialogFirstRow>>>label {
		height:41px;
		display:inline-block;
	}
</style>